﻿<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <title>后台</title>
  <link rel="stylesheet" href="../css/layui-v2.4.3/layui/css/layui.css">
  <script src="../js/jquery-1.11.0.js" type="text/javascript" charset="utf-8"></script>
  <script src="../js/jquery.cookie.js" type="text/javascript" charset="utf-8"></script>
  <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
  <script src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
  <link rel="stylesheet" href="../css/manage.css">
  <script src="../js/request.js"></script>
  <script src="../js/manage_jumpwork.js"></script>
  <script type="text/javascript">
    $.removeCookie('admin');
    $.removeCookie('uId');
  </script>
</head>

<body class="layui-layout-body">
  <div class="layui-layout layui-layout-admin">
    <div class="layui-header">
      <div class="layui-logo">作品管理平台</div>
      <!-- 头部区域（可配合layui已有的水平导航） -->
      <ul class="layui-nav layui-layout-right">
        <li class="layui-nav-item">
          <a href="javascript:;">
            <img src="" class="layui-nav-img">
            信息科学与工程学院
          </a>
          <dl class="layui-nav-child">
            <dd><a href="">基本资料</a></dd>
            <dd><a href="">安全设置</a></dd>
          </dl>
        </li>
        <li class="layui-nav-item"><a href="#" onclick="OutLogin()">退出登录</a></li>
      </ul>
    </div>

    <div class="layui-side layui-bg-black">
      <div class="layui-side-scroll">
        <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
        <ul class="layui-nav layui-nav-tree" lay-filter="test">
          <li class="layui-nav-item layui-nav-itemed">
            <a class="" href="./manageworks.html">作品发布</a>
          </li>
          <li class="layui-nav-item">
            <a href="./manage.html" onclick="jumpcatch()">比赛发布</a>
          </li>
          <li class="layui-nav-item"><a href="./managestudent.html" onclick="jumpStudent()">学生管理</a></li>
        </ul>
      </div>
    </div>

    <div class="layui-body">
      <!-- 内容主体区域 -->
      <div style="padding: 0px;">
        <div id="workbox">
          <div>
            <button class="btn btn-primary btn-lg" data-toggle="modal" data-target="#myModal">发布比赛</button>
          </div>
        </div>
        
        
        <div id="gameNews">
          <div class="container">
            <h2 id="catch">比赛咨询</h2><br>
          </div>
          <table class="table table-hover table-striped">
            <thead>
              <tr>
                <th>学院</th>
                <th>比赛名字</th>
                <th>比赛时间</th>
                <th>比赛id</th>
                <th>删除</th>
              </tr>


            </thead>
            <tbody id="studentTable">


            </tbody>
          </table>
        </div>
      </div>
    </div>

    <div class="layui-footer">
      <!-- 底部固定区域 -->
      琴理工作室作品管理平台
    </div>
  </div>
  <script src="../css/layui-v2.4.3\layui/layui.js"></script>
  <script>
    //JavaScript代码区域
  </script>
  <script>
    var sub = $('#sub');
    console.log($('#wrongData').value);
    function load() {
      $ajax({
        method: "GET",
        url: "http://39.97.237.157:8081/api/getcatch",
        success: function (result) {
          console.log(result);
          var z = result.data;
          for (var l = 0; l < z.length; l++) {
            $('#studentTable').append('<tr><td>' + z[l].collage + '</td><td>' + z[l].gName + '</td> <td>待升级</td><td>12</td> <td><button onclick="delet(' + z[l].id + ')">删除</button></td></tr>')
          }
        }
      })
    }
    $ajax({
      method: "GET",
      url: "http://39.97.237.157:8081/api/getcatch",
      success: function (result) {
        console.log(result);
        var z = result.data;
        for (var l = 0; l < z.length; l++) {
          $('#studentTable').append('<tr><td>' + z[l].college + '</td><td>' + z[l].gName + '</td> <td>待升级</td><td>12</td> <td><button onclick="delet(' + z[l].id + ')">删除</button></td></tr>')
        }
      }
    })
    function delet(count) {
      $.post("39.97.237.157:8081/api/deletearticle",
        {
          // 提交时携带的参数
          id: count
          // workname:workname,
          // speakwork:speakwork,
          // inputfile:inputfile
        },
        // 回调函数,data是服务器返回的数据
        function (data, status) {
          var dataObj = data;//转换为json对象
          // dataObj.code是服务器返回的一个数据
          if (dataObj.code == 1) {
            location.href = "./managework.html";
          } else {
            alert(dataObj.msg)
            return;
          }
        });
    }
  </script>
  <!-- 发布比赛模态框 -->
  <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
  aria-hidden="true">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
          &times;
        </button>
        <h4 class="modal-title" id="myModalLabel">
          比赛发布
        </h4>
      </div>
      <div class="modal-body">
        <form role="form" id="submitWorks" method="POST" action="http://39.97.237.157:8081/api/releasegame"
          enctype="multipart/form-data">
          <div class="form-group">
            <label for="name">比赛学院</label>
            <input type="text" class="form-control" placeholder="请输入学院" id="studyCoup" name="college">
            <label for="name">比赛名字</label><span id="wrongData" hidden="hidden">请输入正确的时间格式：2021-02-23</span>
            <input type="text" class="form-control" placeholder="请输入比赛时间" id="studydata" onblur="DataT()"
              name="gName">
            <label for="name">比赛简介</label>
            <textarea class="form-control" rows="3" placeholder="比赛简介" id="speakstudy"
              name="gIntroduction"></textarea>
            <label for="name">比赛封面</label>
            <label for="inputfile">输入文件</label>
            <input type="file" id="inputfile" name="gCImg">
          </div>
          <input type="submit" name="" id="sub" value="提交">
        </form>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
      </div>
    </div><!-- /.modal-content -->
  </div>
  <!-- /.modal -->
</div>
</body>

</html>